package com.blog.feign.fallback;

import com.blog.common.CommonRespDto;
import com.blog.common.RespBean;
import com.blog.feign.SecGoodsFeignClient;
import com.blog.seckill.goods.Good;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName SecGoodsFeignClientFallBack
 * @Destription 远程调用商品服务的兜底回调
 * @Author 天堂小野花
 * @Date 2025/8/23  13:01
 * @Version 1.0
 */
@Slf4j
@Component
public class SecGoodsFeignClientFallBack implements SecGoodsFeignClient {
    @Override
    public CommonRespDto selectAllGoods() {
        log.info("----------------商品服务兜底回调----------------");
        Good good = new Good();
        good.setProductSpuName("未知商品");
        ArrayList<Good> goodArrayList = new ArrayList<>();
        goodArrayList.add(good);
        CommonRespDto respDto = CommonRespDto.success(goodArrayList);
        return respDto;
    }

    @Override
    public Good selectGoodById(Integer rid) {
        log.info("----------------商品查询兜底回调----------------");
        Good good = new Good();
        good.setProductSpuName("未知商品");
        good.setProductSkuPrice(new BigDecimal(0));
        return good;
    }

    @Override
    public int goodInventoryNumById(Integer goodId, Integer num) {
        log.info("----------------商品库存减少兜底回调----------------");
        return 0;
    }


}
